import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:flutter_taotaoshipin/common/translations/en_US.dart';
import 'package:flutter_taotaoshipin/common/translations/zh_CN.dart';
import 'package:flutter_taotaoshipin/value/sp_key.dart';
import 'package:get/get.dart';

class AppTranslations extends Translations {
  static Locale? locale() {
    final String? locale = SpUtil.getString(SpKey.locale);
    switch (locale) {
      case 'zh':
        return const Locale('zh', 'CN');
      case 'en':
        return const Locale('en', 'US');
      default:
        return Get.deviceLocale;
    }
  }

  static List<Locale> supportLocales() {
    return [
      const Locale('zh', 'CN'),
      const Locale('en', 'US'),
    ];
  }

  static Locale? fallbackLocale() {
    return const Locale('zh', 'CN');
  }

  @override
  Map<String, Map<String, String>> get keys => {
        'en_US': en_US,
        'zh_CN': zh_CN,
      };
}
